module Searchable
	extend ActiveSupport::Concern
	#把model中可能用到多次的操作抽象出来放入concern
	# 使用时再用include mixin 混入model

	included do
		include Elasticsearch::Model

		# 数据改变后更新相应的数据
		after_commit on: [:create,:update] do

			#activ_job::base 下异步任务
			# SearchIndexJob.perform_later('index',self.class.name,self.id)
		end

		after_commit on: [:destroy] do

			SearchIndexJob.perform_later('delete',self.class.name,self.id)
		end

	end


end